package com.coordinate.core.kernel.serviceprovider.impl;

import java.io.UnsupportedEncodingException;
import java.util.List;

/*Email Java Mail API*/
import java.util.Properties;
import javax.mail.*;
import javax.mail.internet.*;



import com.coordinate.core.kernel.serviceprovider.EmailServiceProvider;
import com.coordinate.core.kernel.serviceprovider.SmsServiceProvider;
import com.coordinate.core.message.Message;
import com.coordinate.core.transport.Sms;
import com.coordinate.core.transport.VoiceCall;
import com.coordinate.core.type.DeliveryReport;
import com.coordinate.core.type.impl.CUnicodeConverter;
import com.devicemantra.coordinate.tasks.CTask;
import com.devicemantra.coordinate.tasks.CTaskFactory;

public class CVideoCallServiceProvider extends CServiceProvider implements SmsServiceProvider {

	

	public int send(Message pMsg) 
	{
		int lResult = -1;
	    VoiceCall lVoiceCallMsg;
	    List<String> lList;
	    String lEnglishText;
	    
		if(! (pMsg instanceof VoiceCall))
		{
			System.out.println("Sorry, this message cannot be sent as an SMS, throw Exception");
	        return lResult; 		
		}
		
	    lVoiceCallMsg = (VoiceCall)pMsg;
	    
	    lList =  lVoiceCallMsg.getPhoneNumbers();
	    for(String lMobileNumber: lList)
	    {
	    	CTask lVoiceCallTask = CTaskFactory.createNewCallTask();
	        lVoiceCallTask.setTaskUrl("/OutboundCallsWorker");
	    	lVoiceCallTask.addParameter("mobile_number",lMobileNumber);
	    	lVoiceCallTask.addParameter("vm_key",lVoiceCallMsg.getVoiceMessageKey());
	    	lVoiceCallTask.addParameter("lang","en");
	        CTaskFactory.addTaskToQueue(lVoiceCallTask);
	    }
	
		return 0;
	}
	
	
	
	public List<DeliveryReport> getDeliveryReports(String pUniqueMsgId) {
		// TODO Auto-generated method stub
		return null;
	}

	
}
